<template>
  <div class="myTable">
    <el-row class="searchRow">

      <el-select v-model="year" placeholder="选择年" clearable style="margin-right: 15px">
        <el-option
            v-for="item in years"
            :key="item"
            :label="item"
            :value="item">
        </el-option>
      </el-select>

      <el-button type="success" @click="query(1)">查询</el-button>
      <el-button  type="default" @click="clear()" >重置</el-button>
    </el-row>
    <el-table :data="tableData.data" :show-header="true" :header-row-class-name="'tableHead'" :header-cell-class-name="'tableHeadCell'" >
      <el-table-column  type="index" label="NO" :index="indexMethod" width="60px"></el-table-column>
      <!--<el-table-column  label="政策法规类别"  prop="type"></el-table-column>-->
      <el-table-column label="日期" width="140px">
        <template slot-scope="scope">
          <span>{{scope.row.year}}-{{scope.row.month}}-{{scope.row.day}}</span>
        </template>
      </el-table-column>
      <el-table-column  label="内容"  prop="content"></el-table-column>
    </el-table>
    <el-pagination @current-change="query" style="margin-top: 25px"  :current-page="tableData.curPageNO"
                   layout="total,prev, pager, next" :total="tableData.rowsCount" background :page-size="tableData.pageSize"> </el-pagination>

  </div>
</template>
<script>
  /* eslint-disable no-unreachable */

  const years = [2017];
  export default {
    name: "setBigEvent",
    data: function() {
      return {
        years:years,
        year:'',
        tableData: {},
        dialogVisible:false
      }
    },
    methods:{
      indexMethod:function(index){
        return (this.tableData.curPageNO-1)*10+index+1;
      },
      query:function(pageNo){
        let vm = this;
        let data = {
          curPageNO:pageNo,
          pageSize:10,
          year:vm.year,
        }
        this.$http.post("/yczmq/bigScreen/greatdeed/page",window.changeDataType(data)).then(resp => {
          if(resp.status == 0){
            vm.tableData = resp.data;
          }
        })
      },
      clear(){
        this.year = new Date().getFullYear();
      }
    },
    created(){
      this.year = new Date().getFullYear();
      let tmpYear = this.years[this.years.length-1];
      while(tmpYear<this.year){
        this.years.push(++tmpYear)
      }
      this.query(1);
    }
  }
</script>
<style scoped>
</style>
